﻿// Decompiled with JetBrains decompiler
// Type: MCM.Common.StorageRef
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

#nullable enable
namespace MCM.Common
{
  public sealed class StorageRef : IRef, INotifyPropertyChanged
  {
    private object? _value;

    public event PropertyChangedEventHandler? PropertyChanged;

    public Type Type { get; }

    public object? Value
    {
      get => this._value;
      set
      {
        if (object.Equals(this._value, value))
          return;
        this._value = value;
        this.OnPropertyChanged(nameof (Value));
      }
    }

    public StorageRef(object? value)
    {
      this._value = value;
      this.Type = value?.GetType() ?? throw new Exception("Value can't be null!");
    }

    private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
    {
      PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
      if (propertyChanged == null)
        return;
      propertyChanged((object) this, new PropertyChangedEventArgs(propertyName));
    }
  }
}
